package com.hmall.order.common;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MQConfig {

    @Bean
    public Queue OrderQueue(){
        return QueueBuilder.durable("order.queue")  //指定队列名称并持久化
                .deadLetterExchange("dl.ttl.exchange")  //指定死信交换机
                .deadLetterRoutingKey("dl")
                .build();
    }

    @Bean
    public TopicExchange orderExchange(){
        return new TopicExchange("order.topic");
    }

    @Bean
    public Binding bingQueue(){
        return BindingBuilder.bind(OrderQueue()).to(orderExchange()).with("order");
    }
}
